<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        // this和arguments
        // this->函数的调用者
        // arguments->函数的实际调用参数
        var length = 1;
        function fn() {
            console.log(this.length);
        }
        // console.log(fn());
        var obj = {
            length: 100,
            action: function (callback) {
                callback(); //this->window输出1
                // 输出5
                // arguments-> [fn,1,2,3,4]
                // this->5
                arguments[0]();
                var foo = arguments[0];
                foo() //this -> window -> 1
                this.foo2 = arguments[0];
                this.foo2() //this->obj->100
            }
        }
        var arr1 = [1, 2, 3, 4];
        obj.action(fn, ...arr1);
    </script>
</body>

</html>